package com.moonLight.weblog.web.controller;

import com.moonLight.weblog.admin.model.vo.user.UpdateAdminUserPasswordReqVO;
import com.moonLight.weblog.admin.service.AdminUserService;
import com.moonLight.weblog.common.aspect.ApiOperationLog;
import com.moonLight.weblog.common.utils.Response;
import com.moonLight.weblog.web.model.vo.user.UpdateUserPasswordReqVO;
import com.moonLight.weblog.web.model.vo.user.UserPasswordReqVO;
import com.moonLight.weblog.web.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Api(tags = "用户登录模块")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/password/get")
    @ApiOperation(value = "获取邮箱验证码")
    @ApiOperationLog(description = "获取邮箱验证码,用户名可以为null 但是邮箱不能为null")
    public Response getCode(@RequestBody @Validated UserPasswordReqVO userPasswordReqVO) {
        return userService.getCode(userPasswordReqVO);
    }


    @PostMapping("/password/update")
    @ApiOperation(value = "修改密码")
    @ApiOperationLog(description = "修改密码")
    public Response updatePassword(@RequestBody @Validated UpdateUserPasswordReqVO updateUserPasswordReqVO) {
        return userService.updatePassword(updateUserPasswordReqVO);
    }



}
